//package com.camemax.amqp.service.impl;
//
//import com.camemax.amqp.service.RabbitmqConsumerService;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.core.MessageProperties;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.messaging.handler.annotation.Header;
//import org.springframework.messaging.handler.annotation.Headers;
//import org.springframework.messaging.handler.annotation.Payload;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;
//
//import java.io.UnsupportedEncodingException;
//import java.util.Map;
//
///*
//***************************
//*   @Date: 2021-06-12
//*   @Author: Camemax
//*   @Description: Consumers for Score Application
//***************************
//*/
//@Service
//public class RabbitmqConsumerServiceImpl {
//
//    @Component
//    @RabbitListener( queues = {"fail-score-queue"})
//    static class FailScore implements RabbitmqConsumerService{
//        @RabbitHandler
//        @Override
//        public void consumer(String message) {
//            System.out.println("[fail-score-queue] accepts message => " + message );
//        }
//    }
//
//    @Component
//    @RabbitListener( queues = {"pass-score-queue"})
//    static class PassScore implements RabbitmqConsumerService{
//        @RabbitHandler
//        @Override
//        public void consumer(String message) {
//            System.out.println("[pass-score-queue] accepts message => " + message );
//        }
//    }
//
//    @Component
//    @RabbitListener( queues = {"good-score-queue"})
//    static class GoodScore implements RabbitmqConsumerService{
//        @RabbitHandler
//        @Override
//        public void consumer(String message) {
//            System.out.println("[good-score-queue] accepts message => " + message  );
//        }
//    }
//
//    @Component
//    static class ComTopic implements RabbitmqConsumerService{
//        @RabbitListener( queues = {"com-queue"})
//        @Override
//        public void consumer(String message) {
//            System.out.println("[com-queue] accepts message => " + message);
//        }
//    }
//
//    @Component
//    static class StudentsTopic implements RabbitmqConsumerService{
//        @RabbitListener( queues = {"students-queue"})
//        @Override
//        public void consumer(String message) {
//            System.out.println("[students-queue] accepts message => " + message);
//        }
//    }
//
//    @Component
//    static class NameTopic implements RabbitmqConsumerService{
//        @RabbitListener( queues = {"name-queue"})
//        @Override
//        public void consumer(String message) {
//            System.out.println("[name-queue] accepts message => " + message);
//        }
//    }
//
//    @Component
//    static class TestTopic implements RabbitmqConsumerService{
//        @RabbitListener( queues = {"test-queue"})
//        @Override
//        public void consumer(String message) {
//            System.out.println("[test-queue] accepts message => " + message);
//        }
//    }
//
//    @Component
//    static class IdHeaders {
//        @RabbitListener( queues = {"id-queue"} )
//        // 通过@Payload获取body信息， @Headers获取headers信息
//        public void headersConsumer(Message message, @Payload String body, @Headers Map<String, Object> headers) throws UnsupportedEncodingException {
//            MessageProperties messageProperties = message.getMessageProperties();
//            String contentType = messageProperties.getContentType();
//            System.out.println("body => "+body);
//            System.out.println("header =>" +headers);
////            System.out.println(contentType); UTF-8
//            System.out.println("[id-queue] accepts messages => " + new String(message.getBody(), contentType));
//        }
//    }
//
//    @Component
//    static class CoffeeHeaders implements RabbitmqConsumerService {
//        @RabbitListener( queues = {"coffee-queue"} )
//        @Override
//        public void consumer(String message) {
//            System.out.println("[coffee-queue] accepts message => " + message);
//        }
//    }
//}
